package com.cmcc.driver.data.entity

import android.os.Parcel
import android.os.Parcelable

data class OrderDetail(
    val id: String?,
    val remark: String?,
    val type: Int,
    val stationIndex: String?,
    val mileageFee: String?,
    val bountyFee: String?,
    val totalAmount: String?,
    val payMethod: String?,
    val startAddress: String?,
    val endAddress: String?,
    val status: Int,
    val createTime: String?,
    val overTime: String?,
    var startCoordinates: Coordinates?,
    var endCoordinates: Coordinates?,
    var tunnel: Tunnel?,
    val tunnelName:String?,
    val tunnelCode:String?,
    val vehicleTypeName:String?,
    val vehicleTypeCode:String?,
    var passenger: Passenger?,
    var startTime: String?

) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString(),
        parcel.readString(),
        parcel.readInt(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readInt(),
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(Coordinates::class.java.classLoader),
        parcel.readParcelable(Coordinates::class.java.classLoader),
        parcel.readParcelable(Tunnel::class.java.classLoader),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(Passenger::class.java.classLoader),
        parcel.readString()
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(remark)
        parcel.writeInt(type)
        parcel.writeString(stationIndex)
        parcel.writeString(mileageFee)
        parcel.writeString(bountyFee)
        parcel.writeString(totalAmount)
        parcel.writeString(payMethod)
        parcel.writeString(startAddress)
        parcel.writeString(endAddress)
        parcel.writeInt(status)
        parcel.writeString(endAddress)
        parcel.writeString(createTime)
        parcel.writeString(overTime)
        parcel.writeParcelable(startCoordinates, flags)
        parcel.writeParcelable(endCoordinates, flags)
        parcel.writeParcelable(tunnel, flags)
        parcel.writeString(tunnelName)
        parcel.writeString(tunnelCode)
        parcel.writeString(vehicleTypeName)
        parcel.writeString(tunnelCode)
        parcel.writeParcelable(passenger, flags)
        parcel.writeString(startTime)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<OrderDetail> {
        override fun createFromParcel(parcel: Parcel): OrderDetail {
            return OrderDetail(parcel)
        }

        override fun newArray(size: Int): Array<OrderDetail?> {
            return arrayOfNulls(size)
        }
    }
}

data class Tunnel(
    val id: String?,
    val name: String?,
    var fee: String?
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString(),
        parcel.readString(),
        parcel.readString()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(name)
        parcel.writeString(fee)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Tunnel> {
        override fun createFromParcel(parcel: Parcel): Tunnel {
            return Tunnel(parcel)
        }

        override fun newArray(size: Int): Array<Tunnel?> {
            return arrayOfNulls(size)
        }
    }
}


data class Passenger(
    val id: String?,
    val name: String?,
    var headPortraitAddress: String?,
    var phone: String?
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(name)
        parcel.writeString(headPortraitAddress)
        parcel.writeString(phone)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Passenger> {
        override fun createFromParcel(parcel: Parcel): Passenger {
            return Passenger(parcel)
        }

        override fun newArray(size: Int): Array<Passenger?> {
            return arrayOfNulls(size)
        }
    }
}
